import React, { Component } from 'react'
import list from './index.module.css'
import { PropTypes } from 'prop-types'

import Item from '../item'

export default class List extends Component {
  // 对props接收传值的类型、必要性的限制
  static propTypes = {
    changeTodos:PropTypes.func.isRequired,
    todos:PropTypes.array.isRequired,
  }
  render() {
    const {todos,changeTodos,delTodos} = this.props
    return (
      <div className={list.index}>
         {//在div里写函数的话需要用大括号包裹
          todos.map((i) =>{
            return <Item key={i.id} {...i} changeTodos={changeTodos}  delTodos={delTodos}/>   
          })
        }
       </div>
    )
  }
}
